package com.atguigu.gmall.order.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.util.UserAuthUtil;
import com.atguigu.gmall.order.biz.OrderBizService;
import com.atguigu.gmall.order.entity.OrderInfo;
import com.atguigu.gmall.order.service.OrderInfoService;
import com.atguigu.gmall.order.vo.OrderconfirmRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/inner/rpc/order")
public class OrderRpcController {
    @Autowired
   private OrderBizService orderBizService;
    @Autowired
    private OrderInfoService  orderInfoService;

    /**
     * 获取订单确认页数据
     * @return
     */
    @GetMapping("/confirmdata")
   public Result<OrderconfirmRespVo> orderConfirmData(){
      OrderconfirmRespVo respVo= orderBizService.getConfirmData();
      return  Result.ok(respVo);
    }

    /**
     * 根据订单id 查询订单
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    public Result<OrderInfo> getOrderById(@PathVariable("id") Long id){
        Long userId = UserAuthUtil.getUserId();
       OrderInfo orderInfo = orderInfoService.getOrderById(id,userId);
      return Result.ok(orderInfo);

    }
}
